cmake_minimum_required(VERSION 3.16)
project(frpc_server C CXX)
set(PROJECT_NAME frpc_server )

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")

set(project_root $ENV{CODE_DIR}/frpc_server)


find_package(OpenSSL REQUIRED)
find_package(workflow REQUIRED CONFIG HINTS $ENV{CODE_DIR}/workflow)
if(WIN32)
set(CPPBASE_LIB $ENV{CODE_DIR}/cppbase/build/Debug/cppbase.lib)
set(Protobuf_LIBRARIES $ENV{CODE_DIR}/protobuf/install/lib/libprotobufd.lib)
set(WORKFLOW_LIB workflow ws2_32 wsock32 OpenSSL::SSL OpenSSL::Crypto)
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /MP /wd4200")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4200 /Zc:__cplusplus /std:c++20")
elseif(UNIX)
find_library(LIBRT rt)
set(WORKFLOW_LIB workflow ${LIBRT})
set(CPPBASE_LIB $ENV{CODE_DIR}/cppbase/build/libcppbase.a)
set(Protobuf_LIBRARIES /usr/local/lib/libprotobuf.a)
endif()
#find_package(Protobuf CONFIG REQUIRED)

link_directories(${WORKFLOW_LIB_DIR})

include_directories(
${project_root}/src 
$ENV{CODE_DIR}/cppbase

if(WIN32)
$ENV{CODE_DIR}/protobuf/install/include
elseif(UNIX)
/usr/local/include #protobuf include files
endif()
${OPENSSL_INCLUDE_DIR} 
${WORKFLOW_INCLUDE_DIR}
)

set(CMAKE_BUILD_TYPE "Debug")

ADD_SUBDIRECTORY(src)


file(GLOB test_SRCS
     "./test/*.cpp"
)
file(GLOB testclient_SRCS
     "./test_client/*.cpp"
)

#aux_source_directory(. frpcserver_SRCS)

add_executable(test_s 

${test_SRCS}
)
add_executable(test_c 
${testclient_SRCS}
)
set(WORKFLOW_LIB workflow ${LIBRT})
set(target_list "test_s" "test_c")

foreach(_var ${target_list})
TARGET_LINK_LIBRARIES(${_var}
${WORKFLOW_LIB}
${CPPBASE_LIB}
#${Protobuf_LIBRARIES}
frpc
task
handler
protocol
filestore
 )
endforeach()





#target_sources(grpc_server PRIVATE ${gserver_SRCS})



